package com.dongdongshop.controller;

import com.dongdongshop.data.Result;
import com.dongdongshop.domain.model.TbItem;
import com.dongdongshop.domain.vo.ItemVO;
import com.dongdongshop.service.TbItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("item")
public class ItemController {

    @Autowired
    private TbItemService itemService;

    //根据id查询item数据
    @GetMapping
    public Result getItemById(@RequestParam Long itemId){
        ItemVO item = itemService.getItemById(itemId);
        return Result.OK().setData(item);
    }

    //批量修改库存
    @PostMapping
    public Result updateByNum(@RequestBody List<ItemVO> itemVOList){
        itemService.updateByNum(itemVOList);
        return Result.OK();
    }

}
